#ifndef CHATVIEW_H
#define CHATVIEW_H
#include"global.h"
#include<QEvent>
#include<QPaintEvent>
#include<QVBoxLayout>
#include<QScrollArea>
#include<QScrollBar>
#include<QHBoxLayout>
#include<QStyleOption>
#include<QPainter>
#include<QStyle>
#include<QTimer>
class ChatView:public QWidget
{
    Q_OBJECT
public:
    ChatView(QWidget*parent=Q_NULLPTR);
    void topInsertChatItem(QWidget* item);//头插
    void bottonInsertChatItem(QWidget* item);//尾插
    void midInsertChatItem(QWidget* before,QWidget* item);//中间插
    void appendChatItem(QWidget* item);
    void removeAllItem();
protected:
    virtual bool eventFilter(QObject *watched, QEvent *event)override;
    virtual void paintEvent(QPaintEvent*event)override;

private slots:
    void onVScrollBarMoved(int min,int max);
private:
    void iniStyleSheet();
private:
    QVBoxLayout* m_pVl;
    QScrollArea* m_pScrollArea;
    bool isInserted;
    bool isAppended;
};

#endif // CHATVIEW_H
